const crypto = require('crypto');
const key = "120734aa834dea925ca8d2e1bb6811c3";
const iv = "33daee8409834c00";

const encrypt = (content) => {
    const cipher = crypto.createCipheriv('aes-256-cbc', Buffer.from(key), Buffer.from(iv));
    let encrypted = cipher.update(content, 'utf-8', 'hex');
    encrypted += cipher.final('hex');
    return encrypted;
}

const decrypt = (content) => {
    const cipher = crypto.createDecipheriv('aes-256-cbc', Buffer.from(key), Buffer.from(iv));
    let decrypted = cipher.update(content, 'hex', 'utf-8');
    decrypted += cipher.final('utf-8');
    return decrypted;
}

module.exports = {
    encrypt,
    decrypt
};